import React, {Component} from "react";
import {
	View,
	Text,
	Platform,
	ToastAndroid,
	BackHandler,
} from "react-native";


export default class MyBack extends Component {
	componentWillMount() {
		if (Platform.OS === 'android') {
			BackHandler.addEventListener("hardwareBackPress", this.onBackAndroid);
		}
	}
	componentWillUnmount() {
		if (Platform.OS === 'android') {
			BackHandler.removeEventListener('hardwareBackPress', this.onBackAndroid);
		}
	}
	onBackAndroid = () => {
		alert(12);
		return true
	}
	render() {
		return (
			<View>
				<Text>android的返回键的使用</Text>
			</View>
		);
	}
}